{template 'web/_header'}
<ul class="nav nav-tabs">
    <li {if ($_GPC['p'] == 'list' || $_GPC['p'] == '') && ($_GPC['op'] == '' || $_GPC['op'] == 'display')}class="active"{/if}><a href="{php echo $this->createWebUrl('authenticity/list')}">抽奖活动</a></li>
    <li {if $_GPC['p'] == 'list' && $_GPC['op'] == 'post'}class="active"{/if}><a href="{php echo $this->createWebUrl('authenticity/list',array('op'=>'post'))}">添加抽奖活动</a></li>
    {if $_GPC['op'] == 'awardlist'}<li class="active"><a href="javascript:;">中奖记录</a></li>{/if}
    {if $_GPC['op'] == 'detail'}<li class="active"><a href="javascript:;">详细信息</a></li>{/if}
    {if $_GPC['op'] == 'qrcode'}<li class="active"><a href="javascript:;">批量生成二维码</a></li>{/if}
    <li {if $_GPC['op'] == 'information'}class="active"{/if}><a href="{php echo $this->createWebUrl('authenticity/list',array('op'=>'information'))}">门店信息</a></li>
    <li {if $_GPC['op'] == 'download'}class="active"{/if}><a href="{php echo $this->createWebUrl('authenticity/list',array('op'=>'download'))}">下载二维码</a></li>
</ul>
{if $operation == 'display'}
<form action="" method="post">
    <div class="panel panel-default">
        <div class="panel-body table-responsive">
            <table class="table table-hover">
                <thead class="navbar-inner">
                    <tr>
                        <th style="width:10%;">ID</th>
                        <th style="width:10%;">抽奖活动ID</th>
                        <th style="width:20%;">活动标题</th>
                        <th style="width:10%;">创建时间</th>
                        <th style="width:10%;">综合中奖率</th>
                        <th style="width:10%;">参与人数</th>
                        <th style="width:10%;">中奖人次</th>
                        <th style="text-align:center;width:10%;">操作</th>
                        <th style="text-align:center;width:10%;">二维码</th>
                    </tr>
                </thead>
                <tbody>
                    {loop $list $row}
                    <tr>
                        <td style="width:10%">{$row['rec_id']}</td>
                        <td style='width:10%'>{$row['lottery_id']}</td>
                        <td style='width:20%'>{$row['title']}</td>
                        <td style='width:10%'>{$row['create_time']}</td>
                        <td style='width:10%'>{$row['rate']}%</td>
                        <td style='width:10%'>{$row['chanyu_num']}</td>
                        <td style='width:10%'>{$row['zhongjiang_num']}</td>
                        <td style='text-align:center;width:10%'>
                            <a href="{php echo $this->createWebUrl('authenticity/list',array('op'=>'awardlist','reply_id'=>$row['lottery_id']))}" class="btn btn-default btn-sm">中奖记录</a>
                        </td>
                        <td style="text-align:center;width:10%">
                            <a href="{php echo $this->createWebUrl('authenticity/list',array('op'=>'qrcode', 'id' => $row['rec_id']))}" class="btn btn-default btn-sm">批量生成</a>
                        </td>
                    </tr>
                    {/loop}
                </tbody>
            </table>
            {$pager}
        </div>
    </div>
</form>
{elseif $operation == 'post'}
<div class="main">
    <form action="" method="post" class="form-horizontal form" enctype="multipart/form-data">
        <div class="panel panel-default">
            <div class="panel-heading">
                添加抽奖活动
            </div>
            <div class="panel-body">
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style="color:red">*</span>抽奖活动</label>
                    <div class="col-sm-9 col-xs-12">
                        <select name="lottery_id" class="form-control">
                            <option value='0'></option>
                            {loop $list $row}
                            <option value="{$row['id']}">{$row['id']}-{$row['title']}</option>
                            {/loop}
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label"></label>
                    <div class="col-sm-9 col-xs-12">
                        <input type="submit" name="submit" value="提交" class="btn btn-primary col-lg-1"  />
                        <input type="hidden" name="token" value="{$_W['token']}" />
                    </div>
                </div>
            </div>
        </div>
    </form>
</div>
{elseif $operation == 'awardlist'}
<form action="" method="post">
    <div class="panel panel-default">
        <div class="panel-body table-responsive">
            <table class="table table-hover">
                <thead class="navbar-inner">
                    <tr>
                        <th style="width:10%;">ID</th>
                        <th style='width:10%'>uid</th>
                        <th style='width:10%'>二维码编号</th>
                        <th style='width:20%'>说明</th>
                        <th style='width:10%'>级别</th>
                        <th style='width:20%'>中奖时间</th>
                        <th style='width:20%'>操作时间</th>
                        <th style='width:10%'>查看详情</th>
                        <th style='width:10%'>状态</th>
                    </tr>
                </thead>
                <tbody>
                    {loop $list $row}
                    <tr>
                        <td>{$row['id']}</td>
                        <td>{$row['uid']}</td>
                        <td>{$row['qid']}</td>
                        <td>{$row['name']}</td>
                        <td>奖品{$row['level']}</td>
                        <td>{php echo date('Y-m-d H:i:s',$row['createtime'])}</td>
                        <td>{php echo date('Y-m-d H:i:s',$row['consumetime'])}</td>
                        <td><a href="{php echo $this->createWebUrl('authenticity/list',array('uid'=>$row['uid'],'op'=>'detail'));}" class="btn btn-default btn-sm">查看详情</a></td>
                        <td>{if $row['status'] == 1}操作成功{/if}</td>
                    </tr>
                    {/loop}
                </tbody>
            </table>
            {$pager}
        </div>
    </div>
</form>
{elseif $operation == 'detail'}
<div class="panel panel-default">
            <div class="panel-heading">
             详细信息
            </div>
            <div class="panel-body">
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;粉丝 ：</label>
                    <div class="col-sm-9 col-xs-12">
                        <img src="{$data['avatar']}" style='width:100px;height:100px;padding:1px;border:1px solid #ccc' />
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;姓名 ：</label>
                    <div class="col-sm-9 col-xs-12">
                        <div class='form-control-static'>{$data['realname']}</div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">手机号码 ：</label>
                    <div class="col-sm-9 col-xs-12">
                        <p class="form-control-static">{$data['mobile']}</p>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">&nbsp;&nbsp;&nbsp;&nbsp;微信号 ：</label>
                    <div class="col-sm-9 col-xs-12">
                        <div class='form-control-static'>{$data['weixin']}</div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;性别 ：</label>
                    <div class="col-sm-9 col-xs-12">
                        <p class="form-control-static">
                         {if $data['gender']==1}
                         男
                         {else}
                         女
                         {/if}
                        </p>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">所在城市 ：</label>
                    <div class="col-sm-9 col-xs-12">
                        <div class='form-control-static'>{$data['province']} {$data['city']} {$data['area']}</div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">公司部门 ：</label>
                    <div class="col-sm-9 col-xs-12">
                        <p class="form-control-static">{$data['company']}</p>
                    </div>
                </div>
            </div>
        </div>

{elseif $operation == 'qrcode'}
<div class="main">
    <form method="post" class="form-horizontal form" enctype="multipart/form-data">
        <div class="panel panel-default">
            <div class="panel-heading">
                批量二维码设置
            </div>
            <div class="panel-body">
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">批量生成二维码ID</label>
                    <div class="col-sm-9 col-xs-12">
                        <div class="form-control" style="border:0">{$_GPC['id']}</div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style="color:red">*</span>回复规则名称</label>
                    <div class="col-sm-9 col-xs-12">
                        <input type="text" id='name' name="name" class="form-control" value="" />
                        <span class="help-block">系统会自动生成一组名称+ID，以区分每一个规则和二维码</span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style="color:red">*</span>触发关键字</label>
                    <div class="col-sm-9 col-xs-12">
                        <input type="text" id='keyword' name="keyword" class="form-control" value="" />
                        <span class="help-block">系统会自动生成一组关键字+ID，以区分每一个推送消息</span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style="color:red">*</span>图文消息标题</label>
                    <div class="col-sm-9 col-xs-12">
                        <input type="text" id='title' name="title" class="form-control" value="" />
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">封面</label>
                    <div class="col-sm-9 col-xs-12">
                        {php echo tpl_form_field_image('thumb', '')}
                        <span class="help-block">封面，建议尺寸: 360像素 * 200像素 </span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">描述</label>
                    <div class="col-sm-9 col-xs-12">
                        <input type="text" id='description' name="description" class="form-control" value="" />
                        <span class="help-block">添加图文消息的简短描述</span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style="color:red">*</span>需要生成二维码数量</label>
                    <div class="col-sm-9 col-xs-12">
                        <input type="text" id='number' name="number" class="form-control" value="" />
                        <span class="help-block"></span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style="color:red">*</span>公司名称</label>
                    <div class="col-sm-9 col-xs-12">
                        <input type="text" id='company' name="company" class="form-control" value="" />
                        <span class="help-block"></span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style="color:red">*</span>产品品牌</label>
                    <div class="col-sm-9 col-xs-12">
                        <input type="text" id='brandname' name="brandname" class="form-control" value="" />
                        <span class="help-block"></span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style="color:red">*</span>产品名称</label>
                    <div class="col-sm-9 col-xs-12">
                        <input type="text" id='goodsname' name="goodsname" class="form-control" value="" />
                        <span class="help-block"></span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style="color:red">*</span>生产日期</label>
                    <div class="col-sm-9 col-xs-12">
                        <input type="text" id='production_time' name="production_time" class="form-control" value="" />
                        <span class="help-block">案例：1997-01-01 18:00</span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">二维码类型</label>
                    <div class="col-sm-9 col-xs-12">
                        <!--<label for="radio_0" class="radio-inline"><input type="radio" name="qrc-model" id="radio_0" onclick="$('#model1').hide();
                                $('#model2').show();" value="2"  checked='checked'/> 永久</label>-->
                        <label for="radio_2" class="radio-inline"><input type="radio" name="qrc-model" id="radio_2" onclick="$('#model1').hide();
                                $('#model2').show();" value="3"  checked='checked'/>系统生成</label>
                    </div>
                </div>
                <div class="form-group"></div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label"></label>
                    <div class="col-sm-9 col-xs-12">
                       	<input type="submit" name="submit" value="提交" class="btn btn-primary col-lg-1"  />
                        <input type="hidden" name="token" value="{$_W['token']}" />
                        <input type="button" name="back" onclick='history.back()' style='margin-left:10px;' value="返回列表" class="btn btn-default" />
                    </div>
                </div>
            </div>
        </div>
    </form>
</div>
{elseif $operation == 'download'}
<form action="" method="post">
    <div class="panel panel-default">
        <div class="panel-body table-responsive">
            <table class="table table-hover">
                <thead class="navbar-inner">
                    <tr>
                        <th style="width:10%">ID</th>
                        <th style="width:30%">名称</th>
                        <th style="width:20%">创建时间</th>
                        <th style='width:40%'>操作</th>
                    </tr>
                </thead>
                <tbody>
                    {loop $list $row}
                    <tr>
                        <td style="width:10%">{$row['id']}</td>
                        <td style='width:30%'>{$row['name']}</td>
                        <td style='width:20%'>{$row['createtime']}</td>
                        <td style="text-align:left;width:40%">
                            <a href="{$row['downlink']}" class="btn btn-default btn-sm">
                                下载压缩包</a>
                            <a href="{$row['deletelink']}" 
                               class="btn btn-default btn-sm" onclick="return confirm('确认删除此压缩包?')" title="删除"><i class="fa fa-times"></i>删除压缩包
                            </a>
                        </td>
                    </tr>
                    {/loop}
                </tbody>
            </table>
            {$pager}
        </div>
    </div>
</form>
{/if}
{if $operation == 'information'}
<form action="./index.php" method="get" class="form-horizontal" role="form" >
    <input type="hidden" name="c" value="site">
    <input type="hidden" name="a" value="entry">
    <input type="hidden" name="p" value="list">
    <input type="hidden" name="op" value="information">
    <input type="hidden" name="do" value="authenticity">
    <input type="hidden" name="m" value="ewei_shop">
    <div class="panel panel-info">
        <div class="panel-heading">筛选</div>
        <div class="panel-body">
            <div class="form-group">
                <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">编号QID</label>
                <div class="col-sm-8 col-lg-9 col-xs-12">
                    <input type="text" class="form-control"  name="qid" value="{$_GPC['qid']}" placeholder=""/> 
                </div>
            </div>
            <div class="form-group">
                <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">公司名称</label>
                <div class="col-sm-8 col-lg-9 col-xs-12">
                    <input type="text" class="form-control"  name="company" value="{$_GPC['company']}" placeholder=""/> 
                </div>
            </div>
            <div class="form-group">
                <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">产品品牌</label>
                <div class="col-sm-8 col-lg-9 col-xs-12">
                    <input type="text" class="form-control"  name="brandname" value="{$_GPC['brandname']}" placeholder=""/> 
                </div>
            </div>
            <div class="form-group">
                <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">产品名称</label>
                <div class="col-sm-8 col-lg-9 col-xs-12">
                    <input type="text" class="form-control"  name="goodsname" value="{$_GPC['goodsname']}" placeholder=""/> 
                </div>
            </div>
            <div class="form-group">
                <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">会员信息</label>
                <div class="col-sm-8 col-lg-9 col-xs-12">
                    <input type="text" class="form-control"  name="realname" value="{$_GPC['realname']}" placeholder="可搜索微信号/姓名/手机号"/> 
                </div>
                <div class="col-sm-3 col-lg-2">
                    <button class="btn btn-default"><i class="fa fa-search"></i> 搜索</button>
                    <input type="hidden" name="token" value="{$_W['token']}" />
                    <button type="submit" name="export" value="1" class="btn btn-primary">导出 Excel</button>
                </div>
            </div>
        </div>
    </div>
    <div class="panel panel-default">
        <div class="panel-body table-responsive">
            <table class="table table-hover">
                <thead class="navbar-inner">
                    <tr>
                        <th style="width:10%;">编号QID</th>
                        <th style='width:10%'>粉丝</th>
                        <th style='width:10%'>抽奖活动ID</th>
                        <th style='width:10%'>公司名称</th>
                        <th style='width:10%'>产品品牌</th>
                        <th style='width:10%'>产品名称</th>
                        <th style='width:10%'>生产日期</th>
                        <th style='width:10%'>提交时间</th>
                        <th style='width:20%'>门店地址</th>
                        <th style='width:10%'>门店名称</th>
                    </tr>
                </thead>
                <tbody>
                    {loop $record $row}
                    <tr>
                        <td>{$row['qid']}</td>
                        <td><img src='{$row['avatar']}' style='width:30px;height:30px;padding1px;border:1px solid #ccc' /> {$row['nickname']}</td>
                        <td>{$row['auth_id']}</td>
                        <td>{$row['company']}</td>
                        <td>{$row['brandname']}</td>
                        <td>{$row['goodsname']}</td>
                        <td>{if $row['production_time']}{php echo date('Y-m-d H:i',$row['production_time'])}{/if}</td>
                        <td>{if $row['createtime']}{php echo date('Y-m-d H:i',$row['createtime'])}{/if}</td>
                        <td>{$row['province']} {$row['city']} {$row['area']} {$row['address']}</td>
                        <td>{$row['information']}</td>
                    </tr>
                    {/loop}
                </tbody>
            </table>
            {$pager}
        </div>
    </div>
</form>
{/if}
{template 'web/_footer'}